<?php
/**
 * @author 河南邦耀网络科技
 * @copyright Copyright (c) 2018 HNBY Network Technology Co., Ltd.
 * @link http://www.hnbangyao.com
 */
namespace app\common\library;
use Exception;
use OSS\Core\OssException;
use OSS\OssClient;

/**
 * Aliyun云存储
 * Class Client
 * @package common\components\wsd
 */
class Face
{
    public $code = "";
    public function __construct()
    {
        $this->code = "cbc4829dd43b4553b25bfba5ab824ec7";
    }
    /**
     * 提交信息
     */
    public function postInfo($data)
    {
        $host = "https://faceidcardb.shumaidata.com";
        $path = "/getfaceidb";
        $method = "POST";
        $headers = array();
        array_push($headers, "Authorization:APPCODE " . $this->code);
        //根据API的要求，定义相对应的Content-Type
        array_push($headers, "Content-Type".":"."application/x-www-form-urlencoded; charset=UTF-8");
        $querys = "";
        $bodys = "idcard=".$data['idcard']."&image=".urlencode($data['thumb'])."&name=".$data['username'];
        $url = $host . $path;

        $curl = curl_init();
        curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($curl, CURLOPT_FAILONERROR, false);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_HEADER, true);
        if (1 == strpos("$".$host, "https://"))
        {
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
        }
        curl_setopt($curl, CURLOPT_POSTFIELDS, $bodys);
        $data = curl_exec($curl);
        return $data;
    }
}
